<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>联币ICO</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/bootstrap-theme.css">
    <link rel="stylesheet" type="text/css" href="__ROOT__/css/common.css">
</head>
<body>
<div class="wrap container-fluid">
    <form action="/index/index/upRecharge" class="reg-form" method="post" accept-charset="utf-8">
        <div class="form-group">
            <h1>BTC充值</h1>
        </div>
        <div class="form-group">
            <label style="font-size: 16px">付币地址:</label>
            <input type="text" name="btc_address" class="form-control" id="btc_address"  oninput="check_address(this);" id="BTC" placeholder="请输入付币地址">
        </div>
        <!-- 用户手机号 -->
        <div class="form-group">
            <label style="font-size: 16px">确认地址:</label>
            <input type="text" name="re_btc_address" class="form-control" id="re_btc_address" oninput="check_address(this);"  placeholder="请确认付币地址">
        </div>
        <div class="form-group">
            <label style="font-size: 16px">付币数量:</label>
            <input type="text" name="number" class="form-control" oninput="check_number();" id="num" placeholder="请输入BTC数量">
        </div>
        <div class="form-group">
            <label style="font-size: 16px">长按以下地址复制:</label>
            <p class="form-control">{$toAddress}</p>
        </div>
        <div class="form-group">
            <button type="submit" class="btn btn-success">转入</button>
        </div>
    </form>
    <input type="hidden" name="" class="error" value="{$error ?: ''}">
</div>
<script type="text/javascript" src='__ROOT__/js/jquery.js'></script>
<script type="text/javascript" src='__ROOT__/layer/layer.js'></script>
<script type="text/javascript">
    //数量验证
    function check_number(){
        var num = $('#num').val();
        var reg = /\d+/;
        if(!reg.test(num)){
            $('#num').val('');
        }
    }
    //验证钱包地址
    function check_address(index){
        var reg = /^[A-Za-z0-9]+$/;
        var val = $(index).val();
        if(!reg.test(val)){
            $(index).val('');
        }
    }
    //验证空值
    $(function () {
        $('form').submit(function () {
            // if (!$('input[type="text"]').val()) {
            //     layer.msg('请填写每项信息！');
            //     return false;
            // }
            if($('#btc_address').val()==''){
                layer.msg($('#btc_address').attr('placeholder'));
                return false;
            }
            if($('#re_btc_address').val()==''){
                layer.msg($('#re_btc_address').attr('placeholder'));
                return false;
            }
            if($('#num').val()==''){
                layer.msg($('#num').attr('placeholder'));
                return false;
            }
            var address = $('input[name="btc_address"]');
            var re_address = $('input[name="re_btc_address"]');
            if (address.length != 0 && address.val() != re_address.val()) {
                layer.msg('两次地址不一致！')
                return false
            }
            $.post("{:url('upRecharge')}",$('form').serialize(),function(e){
                if(e.code==1){
                    layer.msg(e.msg,{icon:1,time:2000});
                    setTimeout("window.location.href='"+e.url+"'",2000);
                }else{
                    layer.msg(e.msg,{icon:2,time:2000});
                }
            })
            return false;
        })
        if ($('.error').val()) {
            layer.alert($('.error').val(), {icon: 5})
        }
    })

</script>
</body>
</html>